import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Lily
 * Date: 2024-10-14
 * Time: 19:49
 */
public class test_2 {
    /**
     * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
     * <p>
     * max increasing subsequence
     *
     * @param arr int整型一维数组 the array
     * @return int整型
     */
    public int MLS(int[] arr) {
        Arrays.sort(arr);
        int ret = 0;
        for (int i = 0; i < arr.length; i++) {
            int sum = 0;
            int j = i;
            while (j < arr.length - 1) {
                if (arr[j + 1] - arr[j] == 1) {
                    sum++;
                    j++;
                } else if (arr[j + 1] - arr[j] == 0) {
                    j++;
                } else {
                    break;
                }
            }
            i = j;
            ret = Math.max(ret, sum);
        }

        return ret + 1;
    }
}
